/* 二叉树节点类 */
class TreeNode {
  val: number;
  left: TreeNode | null;
  right: TreeNode | null;

  constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) {
      this.val = val === undefined ? 0 : val; // 节点值
      this.left = left === undefined ? null : left; // 左子节点引用
      this.right = right === undefined ? null : right; // 右子节点引用
  }
}
export default TreeNode

/* 初始化二叉树 */
// 初始化节点
let n1 = new TreeNode(1),
    n2 = new TreeNode(2),
    n3 = new TreeNode(3),
    n4 = new TreeNode(4),
    n5 = new TreeNode(5),
    n6 = new TreeNode(6),
    n7 = new TreeNode(7)
// 构建节点之间的引用（指针）
n1.left = n2;
n1.right = n3;
n2.left = n4;
n2.right = n5;
n3.left = n6
n3.right = n7

n7.left = new TreeNode(8)
export {
  n1
}